<?php
namespace Communal\Controller;
use Common\Controller\CommonController;

/**
 * 公用模块
 */
class CommunalController extends CommonController {
	
	protected function _initialize(){
		parent::_initialize();
	}
	
	
    /**
     * 获取文件
     */
    public function getFileAction(){
    	$fileid = (int)I('request.fileid');
    	$filehash = I('request.filehash');   //文件hash值
    	$w = (int)I('request.w');
    	$h = (int)I('request.h');
    	$this->_getFile($fileid , $filehash , $w , $h);
    }
    
    
    
    /**
     * 获取头像
     */
    public function avatarAction(){
    	$id = (int)I('request.id');
    	$type = (int)I('request.type');   //1.用户头像 ， 2.群头像
    	$w = (int)I('request.w');
    	$h = (int)I('request.h');
    	$this->_avatar($id , $type , $w , $h);
    }
    
    
    /**
     * 获取时间戳
     */
    public function getTimestampAction(){
    	$this->data = time();
    	$this->outPut();
    }
    
    
    /**
     * 二维码页面信息
     */
    public function getQrCodeInfoAction(){
    	$data = I('request.data');
    	$data = json_decode(\aes::decrypt($data , C('TOKEN_SALT')) , true);
    	
    	$isself = (int)I('request.isself');
    	if(!empty($isself)){
    		$this->data = $data;
    		$this->outPut();
    	}else{
    		redirect(C('DOWNLOAD_URL'));
    	}
    	

    }
}
